﻿<%@ Page Language="C#" MasterPageFile="~/WebShop.master" AutoEventWireup="true" CodeFile="Register.aspx.cs"
    Inherits="Member_Register_Register" Title="Đăng ký thành viên" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <link href="<%= ResolveClientUrl("~/")%>Pub/Css/JQ/pass_strenght.css" rel="stylesheet"
        type="text/css" />

    <script src="<%= ResolveClientUrl("~/")%>Pub/Js/JQ/jquery.pstrength-min.1.2.js"></script>

    <script>
			$(document).ready( function() {

				//BASIC				
				$("#<%=txtPassword.ClientID %>").pstrength();
			
			});
    </script>

    <div class="div_skin-tango">
        <div class="coverlblTitleProduct" style="margin: 0px auto;">
            <asp:Label ID="Label16" runat="server" CssClass="lblTitleProduct" Text="ĐĂNG KÝ THÀNH VIÊN MỚI"></asp:Label>
        </div>
        <table border="0" class="tbl_ContentNews" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right" valign="middle" class="td_ContentNews" style="width: 540px; height: 223px">
                    <table cellpadding="2" cellspacing="0" class="tbl_Info" width="100%">
                        <tr>
                            <td align="left" class="td_SubRegisterTitle" colspan="2">
                                <asp:Label ID="Label2" runat="server" Text="Thông tin khách hàng" CssClass="link_Title1"
                                    Font-Bold="true"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                            </td>
                            <td align="left" style="width: 400px">
                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="GrRegister"
                                    CssClass="valid_common" ShowMessageBox="True" ShowSummary="False" />
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                &nbsp;<asp:Label ID="Label4" runat="server" Text="Tên khách hàng:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left">
                                <asp:TextBox ID="txtName" runat="server" ValidationGroup="GrRegister" Width="80%"
                                    CssClass="txt_Common"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
                                    ErrorMessage="Nhập vào tên khách hàng" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                <asp:Label ID="Label5" runat="server" Text="Ngày sinh:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="drlDay" runat="server" CssClass="ddl_Info">
                                </asp:DropDownList>
                                <asp:DropDownList ID="drlMonth" runat="server" CssClass="ddl_Info">
                                </asp:DropDownList>&nbsp;<asp:DropDownList ID="drlYear" runat="server" CssClass="ddl_Info">
                                </asp:DropDownList><span style="font-family: Arial"> </span>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                &nbsp;<asp:Label ID="Label6" runat="server" Text="Giới tính:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left" style="width: 400px">
                                <asp:DropDownList ID="DrlSex" runat="server" CssClass="ddl_Info">
                                    <asp:ListItem Selected="True">Nam</asp:ListItem>
                                    <asp:ListItem>Nữ</asp:ListItem>
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                &nbsp;<asp:Label ID="Label9" runat="server" Text="Email:" CssClass="lbl_Common"></asp:Label>&nbsp;
                            </td>
                            <td align="left" style="width: 400px">
                                <asp:TextBox ID="txtEmail" runat="server" onblur="fnCheckEmail(this.value)" onkeyup="fnHideImgEmail()"
                                    ValidationGroup="GrRegister" CssClass="txt_Common" Width="50%"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtEmail"
                                    ErrorMessage="Nhập vào Email" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                                    ErrorMessage="Nhập chính xác địa chỉ Email" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                                    ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RegularExpressionValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator51" runat="server" ControlToValidate="hidEmail"
                                    ErrorMessage="Email này đã được sử dụng" InitialValue="0" ValidationGroup="GrRegister"
                                    CssClass="valid_common"> &nbsp;</asp:RequiredFieldValidator>&nbsp;
                                <img src='<%= ResolveUrl("~/") %>Images/Icon/spinner.gif' border="0" id="imgStateEmail"
                                    style="visibility: hidden" class="lbl_Normal1" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator52" runat="server" ControlToValidate="hidEmail"
                                    ErrorMessage="Đang xử lý..." ValidationGroup="GrRegister" CssClass="valid_common">Đang xử lý...</asp:RequiredFieldValidator>
                                <asp:TextBox ID="hidEmail" runat="server" CssClass="cssHidden" Text="0" Width="5px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                &nbsp; &nbsp;<asp:Label ID="Label8" runat="server" Text="Điện thoại:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left">
                                <asp:TextBox ID="txtPhone" runat="server" ValidationGroup="GrRegister" CssClass="txt_Common"
                                    Width="50%"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="txtPhone"
                                    ErrorMessage="Số điện thoại phải là số" ValidationExpression="^\d+$" ValidationGroup="GrRegister"
                                    CssClass="valid_common">*</asp:RegularExpressionValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="txtPhone"
                                    ErrorMessage="Nhập vào điện thoại" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                &nbsp;<asp:Label ID="Label7" runat="server" Text="Địa chỉ:" CssClass="lbl_Common"></asp:Label>&nbsp;
                            </td>
                            <td align="left" style="width: 400px; color: #ff6600">
                                <span style="font-family: Arial"></span>
                                <asp:TextBox ID="txtAddress" runat="server" ValidationGroup="GrRegister" CssClass="txt_Common"
                                    Width="80%"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtAddress"
                                    ErrorMessage="Nhập vào địa chỉ" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                <asp:Label ID="Label10" runat="server" Text="Tỉnh/Thành phố:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left">
                                <asp:DropDownList ID="ddlPlace" runat="server">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="ddlPlace"
                                    ErrorMessage="Chọn vào Tỉnh-Thành Phố" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 148px">
                                <asp:Label ID="Label14" runat="server" CssClass="lbl_Common" Text="Mã số thuế:"></asp:Label></td>
                            <td align="left">
                                <asp:TextBox ID="txtTaxNo" runat="server" CssClass="txt_Common" onblur="fnCheckEmail(this.value)"
                                    onkeyup="fnHideImgEmail()" ValidationGroup="GrRegister" Width="50%"></asp:TextBox>
                                <asp:Label ID="Label15" runat="server" CssClass="valid_common" Font-Names="tahoma"
                                    Font-Size="10pt" ForeColor="Red" Text="(Nếu có)"></asp:Label></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="td_ContentNews">
                    <table cellpadding="2" cellspacing="0" style="width: 100%">
                        <tr>
                            <td align="left" colspan="2" nowrap="nowrap" class="td_SubRegisterTitle">
                                <asp:Label ID="Label3" runat="server" Text="Thông tin đăng nhập" CssClass="link_Title1"
                                    Font-Bold="true"></asp:Label></td>
                        </tr>
                        <tr>
                            <td class="cssManage_left" align="right" style="width: 151px">
                                <p style="margin-top: 3px; margin-bottom: 3px; margin-right: 5px">
                                    <font>&nbsp;<asp:Label ID="Label11" runat="server" Text="Tên truy cập:" CssClass="lbl_Common"></asp:Label></font></p>
                            </td>
                            <td align="left" nowrap="nowrap">
                                <asp:TextBox ID="txtUser" runat="server" onblur="fnCheckUser(this.value)" onkeyup="fnHideImg()"
                                    ValidationGroup="GrRegister" CssClass="txt_Common" Width="50%"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtUser"
                                    ErrorMessage="Nhập vào tên truy cập" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="hidUser"
                                    ErrorMessage="Tên truy cập này đã tồn tại" InitialValue="0" ValidationGroup="GrRegister"
                                    CssClass="valid_common"> &nbsp;</asp:RequiredFieldValidator>&nbsp;
                                <img src='<%= ResolveUrl("~/") %>Images/Icon/spinner.gif' border="0" id="imgState"
                                    style="visibility: hidden" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="hidUser"
                                    ErrorMessage="Đang xử lý..." ValidationGroup="GrRegister" CssClass="valid_common">Đang xử lý...</asp:RequiredFieldValidator>
                                <asp:TextBox ID="hidUser" runat="server" CssClass="cssHidden" Text="0" Width="5px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td class="cssManage_left" align="right" style="width: 151px; height: 23px; vertical-align: top">
                                <asp:Label ID="Label12" runat="server" Text="Mật khẩu:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left" style="width: 400px; height: 23px;">
                                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" ValidationGroup="GrRegister"
                                    CssClass="txt_Common" Width="50%"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtPassword"
                                    ErrorMessage="Nhập vào mật khẩu" ValidationGroup="GrRegister" CssClass="valid_common">*</asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="cssManage_left" align="right" style="width: 151px" valign="top">
                                <asp:Label ID="Label13" runat="server" Text="Nhập lại mật khẩu:" CssClass="lbl_Common"></asp:Label>
                            </td>
                            <td align="left" style="width: 400px; height: 20px" valign="top">
                                <asp:TextBox ID="txtTestPassword" runat="server" TextMode="Password" ValidationGroup="GrRegister"
                                    CssClass="txt_Common" Width="50%" Style="float: left;"></asp:TextBox>
                                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtPassword"
                                    ControlToValidate="txtTestPassword" ErrorMessage="Mật khẩu chưa trùng khớp" ValidationGroup="GrRegister"
                                    CssClass="valid_common">*</asp:CompareValidator></td>
                        </tr>
                        <tr>
                            <td align="right" class="cssManage_left" style="width: 151px">
                            </td>
                            <td align="left" style="width: 400px">
                                <asp:CheckBox ID="chkAgree" runat="server" onclick="fnCheckRules(this)" ValidationGroup="GrRegister" />
                                <asp:Label ID="lblRules" runat="server" CssClass="lbl_Normal1" Style="cursor: pointer"></asp:Label>
                                <asp:RequiredFieldValidator ID="RefRules" runat="server" ValidationGroup="GrRegister"
                                    CssClass="valid_common" ControlToValidate="hidAgreeRule">*</asp:RequiredFieldValidator>
                                <asp:TextBox ID="hidAgreeRule" runat="server" ValidationGroup="GrRegister" CssClass="cssHidden"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" class="cssManage_left" style="width: 151px">
                            </td>
                            <td align="left" style="width: 400px">
                            </td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 151px">
                            </td>
                            <td align="left">
                                <asp:Button ID="btnSend" runat="server" Text="Đăng ký" ValidationGroup="GrRegister"
                                    CssClass="btn_Common" OnClick="btnSend_Click" />
                                <br />
                                <br />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>

    <script language="javascript" type="text/javascript">
    // Removes leading whitespaces
    String.prototype.trim = function () {
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}

    /*=================User================*/
    function fnHideImg()
    {
        var imgState=document.getElementById("imgState");
        imgState.style.visibility="hidden"; 
    }
    function fnCheckUser(sValue)
    {      
    
        if(sValue.trim()=="") return;
        Member_Register_Register.AjaxCheckUser(sValue,CallBackUser);  
        var imgState=document.getElementById("imgState");
        imgState.style.visibility="visible";
        imgState.src="../../Images/Icon/spinner.gif";     
    }
    function CallBackUser(res)
    {
        var url='<%= ResolveClientUrl("~/")%>';
        if(res!=null)
        {
            var flag=res.value;
            if(flag!=null && flag!="")
			{	
			    var imgState=document.getElementById("imgState");
			    //var hidUser=document.getElementById("ctl00_ContentPlaceHolder1_hidUser");
			    var hidUser=document.getElementById("<%= hidUser.ClientID%>");
			    hidUser.value="aaa";
			    imgState.style.visibility="visible";
			    if(flag=="yes")
			    {
			        imgState.src=url+"Images/Icon/cmdDelete.gif";
			        imgState.alt="Tên này đã tồn tại";
			        hidUser.value="0";
			    }
			    else
			    {
			        imgState.src=url+"Images/Icon/check.gif";
			        imgState.alt="Bạn được sử dụng tên này";
			    }
			}	
        }
    }
    
/*=================Email================*/
    function fnHideImgEmail()
    {
        var imgStateEmail=document.getElementById("imgStateEmail");
        imgStateEmail.style.visibility="hidden"; 
    }
    function fnCheckEmail(sValue)
    {      
        if(sValue.trim()=="")  return;
        Member_Register_Register.AjaxCheckEmail(sValue,CallBackEmail);  

     
    }
    function CallBackEmail(res)
    {
           var url='<%= ResolveClientUrl("~/")%>';
        if(res!=null)
        {
            var flag=res.value;
            if(flag!=null && flag!="")
			{	
			    var imgStateEmail=document.getElementById("imgStateEmail");

			    var hidEmail=document.getElementById("<%= hidEmail.ClientID%>");
			    hidEmail.value="aaa"; //Tranh su kien dang su ly
		
			    if(flag=="yes")
			    {   imgStateEmail.style.visibility="visible";
			        imgStateEmail.src=url+"Images/Icon/cmdDelete.gif";
			        imgStateEmail.alt="Email này đã tồn tại";			        
			        hidEmail.value="0";
			       
			    }		
			    else
			    {
			           imgStateEmail.style.visibility="hidden";
			    }	    
			}	
        }
    }
    function fnCheckRules(obj)
    {
        var hidAgreeRule=document.getElementById("<%= hidAgreeRule.ClientID%>");    
        if(obj.checked==true)
        {
		    hidAgreeRule.value="aaa";
        }
        else
        {
            hidAgreeRule.value="";
        }
    }
    </script>

</asp:Content>
